package com.woniu.uums.service.impl;

import com.woniu.common.dto.UserDto;
import com.woniu.common.utils.ResponseData;
import com.woniu.common.utils.UserUtil;
import com.woniu.uums.dto.ZsbJwtDto;
import com.woniu.uums.feign.ZsbOrderFeign;
import com.woniu.uums.mapper.ZfMenuMapper;
import com.woniu.uums.pojo.ZfMenu;
import com.woniu.uums.pojo.ZfPoweruserRole;
import com.woniu.uums.service.ZsbMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ZsbMenuServiceImpl implements ZsbMenuService {
    @Autowired
    private ZfMenuMapper zfMenuMapper;
    @Autowired
    private ZsbOrderFeign zsbOrderFeign;
    @Override
    public ResponseData<?> queryAllMenu() {
        ZsbJwtDto user = zsbOrderFeign.getUser();
        UserDto user1 = UserUtil.getUser(user.getJwt());
        ZfPoweruserRole zfPoweruserRole = zfMenuMapper.queryByUserId(Long.valueOf(user1.getId()));
        List<ZfMenu> zfMenu = zfMenuMapper.queryAllMenu(zfPoweruserRole.getRoleId());
        return new ResponseData<>().ok(zfMenu);
    }
}
